<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>当前订单</title>
    <link rel="stylesheet" href="__STATIC__/index/assets/sui/dist/css/sm.css">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_2008579_wi32sytndy.css">
    <link rel="stylesheet" href="__STATIC__/index/assets/css/index.css">
    <link rel="stylesheet" href="__STATIC__/index/assets/sui/dist/css/sm-extend.min.css">
    <link rel="stylesheet" href="__STATIC__/index/layui//dist/css/layui.css">
</head>

<body>
<!-- page 容器 -->
<!-- page 容器 -->
<div class="page_group">
    <div class="page">

        <!-- 工具栏 -->
        <div class="content">
            <header class="bar bar-nav">
                <a href="" onclick="javascript:window.history.go(-1);" class="icon icon-left pull-left" data-direction="left"></a>
                <h1 class="title">订单详情</h1>
            </header>
            <div class="card show_order_cont">
                <div class="card-header">
                    {$order.order_title}
                    <span class="icon icon-right pull-right"></span>
                </div>
                <div class="card-content">
                    <div class="card-content-inner">
                        <div class="list-block order_list_one">
                            <ul>
                                <li class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title">服务名称</div>
                                        <div class="item-after">{$order.order_title}</div>
                                    </div>
                                </li>
                                <li class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title">接单时效</div>
                                        <div class="item-after">{:date('Y-m-d: H:i:s',$order.order_outtime)}</div>
                                    </div>
                                </li>
                                <li class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title">备注</div>
                                        <div style="width:70%;float:right;text-align:right">{$order.order_content}</div>
                                    </div>
                                </li>
                                <li class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title">配送费</div>
                                        <div class="item-after">￥{$order.order_price}</div>
                                    </div>
                                </li>
                                <li class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title">下单姓名</div>
                                        <div class="item-after">{$order.user_name}</div>
                                    </div>
                                </li>
                                <li class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title">下单电话</div>
                                        <div class="item-after">{$order.user_phone}</div>
                                    </div>
                                </li>
                                <li class="item-content">
                                    <div class="item-inner">
                                        <div class="item-title">下单地址</div>
                                        <div class="item-after">{$order.user_address}</div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="card-footer">
                    <div class="showorder_btn">
                        <ul class="layui-timeline">
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                <div class="layui-timeline-content layui-text">
                                    <h3 class="layui-timeline-title">{:date('Y-m-d H:i:s',$order.order_ctime)}</h3>
                                    <p>
                                        订单创建成功
                                    </p>
                                </div>
                            </li>
                            {if $order.order_status>=1}
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                <div class="layui-timeline-content layui-text">
                                    <h3 class="layui-timeline-title">{:date('Y-m-d H:i:s',$order.order_ctime)}</h3>
                                    <p>订单已支付</p>
                                </div>
                            </li>
                            {/if}
                            {if $order.order_status==4}
                                <li class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title">{:date('Y-m-d H:i:s',$order.order_otime)}</h3>
                                        <p>
                                            管理员发起退款请求
                                        </p>
                                    </div>
                                </li>
                                <li class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title">{:date('Y-m-d H:i:s',$order.order_otime)}</h3>
                                        <p>
                                            退款成功
                                        </p>
                                    </div>
                                </li>
                            {else /}
                                {if $order.order_status>=2}
                                <li class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title">{:date('Y-m-d H:i:s',$order.order_ctime)}</h3>
                                        <p>
                                            配送员正在马不停蹄奔向你
                                        </p>
                                    </div>
                                </li>
                                {/if}
                                {if $order.order_status>=3}
                                <li class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                    <div class="layui-timeline-content layui-text">
                                        <h3 class="layui-timeline-title">{:date('Y-m-d H:i:s',$order.order_otime)}</h3>
                                        <p>
                                            订单已配送完成，期待下次服务
                                        </p>
                                    </div>
                                </li>
                                {/if}
                            {/if}

                        </ul>
                    </div>
                </div>
                {if $order.order_status==0 }
                <div class="card-footer">
                    <div class="showorder_btn">
                        <p class="buttons-row"><a href="" onclick="del_order({$order.order_num})" class="button button-round">删除订单</a><a href="#" onclick="toPay({$order.order_num})" class="button button-round active">付款</a></p>
                    </div>
                </div>
                {/if}
                {if $tuple && $order.order_status==1 && $order.order_tuple_status==0}
                <div class="card-footer">
                    <div class="showorder_btn">
                        <p class="buttons-row"><a href="" onclick="toTuple({$order.order_num})" class="button">接单</a></p>
                    </div>
                </div>
                {/if}
                {if $tuple && $order.order_tuple_status==1}
                <div class="card-footer">
                    <div class="showorder_btn">
                        <p class="buttons-row"><a href=""  class="button button-success">已接单</a></p>
                    </div>
                </div>
                {/if}
                {if $tuple && $order.login_user_id==$order.tuple_user_id && $order.order_status!=3}
                <div class="card-footer">
                    <div class="showorder_btn">
                        <p class="buttons-row"><a href="" onclick="overOrder({$order.order_num})" class="button">完成配送</a></p>
                    </div>
                </div>
                {/if}
            </div>
        </div>
    </div>
</div>

</body>
<script src='http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js'></script>
<script src='__STATIC__/index/assets/sui/dist/js/sm.js'></script>
<script src='__STATIC__/index/layui/dist/layui.js'></script>
<script type='text/javascript' src='__STATIC__/index/assets/sui/dist/js/sm-extend.js' charset='utf-8'></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script type="text/javascript" charset="utf-8">
    wx.config({$wxjsconfig|raw});
</script>
<script type="text/javascript" charset="utf-8">
    function del_order(order_num) {
        $.ajax({
            url: "{:url('order/delOrder')}",
            type: "POST",
            data: {
                order_num:order_num
            },
            dataType: "json",
            success: function(res){
                if(res.status){
                    $.toast('订单删除成功，正在返回', 1500);
                    setTimeout(function () {
                        window.location.href="{:url('myorder/index')}";
                    },2000)
                }else{
                    $.toast(res.msg, 1500);
                }
            }
        });
    }
    function toPay(order_num) {
        $.showPreloader('正在调起支付',5000);
        setTimeout(function () {
            $.hidePreloader();
        }, 5000);
        $.ajax({
            url: "{:url('order/pay')}",
            type: "POST",
            data: {
                order_number:order_num
            },
            dataType: "json",
            success: function(res){
                wx.chooseWXPay({
                    timestamp: res.timestamp,
                    nonceStr: res.nonceStr,
                    package: res.package,
                    signType: res.signType,
                    paySign: res.paySign, // 支付签名
                    success: function (res) {
                        window.location.href="{:url('myorder/index')}";
                    },
                    fail:function (data) {

                    }
                });
            }
        });
    }
    function toTuple(order_num) {
        $.ajax({
            url: "{:url('order/tupleOrder')}",
            type: "POST",
            data: {
                order_num:order_num
            },
            dataType: "json",
            success: function(res){
                if(res.code){
                    $.toast(res.msg,2000);
                    setTimeout(function () {
                        window.location.href="{:url('myorder/index')}";
                    })
                }else {
                    $.toast(res.msg,2000);
                }

            }
        });
    }
    function overOrder(order_num) {
        $.ajax({
            url: "{:url('order/overOrder')}",
            type: "POST",
            data: {
                order_num:order_num
            },
            dataType: "json",
            success: function(res){
                if(res.code){
                    $.toast(res.msg,2000);

                }else {
                    $.toast(res.msg,2000);
                }
                setTimeout(function () {
                    window.location.href="{:url('myorder/index')}";
                },2000)
            }
        });
    }
</script>
</html>